# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.
class Order(models.Model):
    order_id = models.CharField(max_length=20,primary_key=True)
    username = models.CharField(max_length=32)
    password = models.CharField(max_length=32)
    login_user=models.CharField(max_length=20)
    train_no = models.CharField(max_length=5)
    train_date = models.DateField()
    passenger = models.CharField(max_length=32)
    seat = models.CharField(max_length=32)
    start_time = models.CharField(max_length=5)
    arrive_time = models.CharField(max_length=5)
    start_station = models.CharField(max_length=20)
    arrive_station = models.CharField(max_length=20)
    state = models.IntegerField()
    update_time = models.DateTimeField(auto_now_add=True)
    remark = models.CharField(max_length=100)
    def __unicode__(self):
        return '%s,%s,%s,%s,%s,%s'%(self.order_id,self.username,self.login_user,self.train_no,self.train_date,self.remark)

class Logs(models.Model):
    ip = models.GenericIPAddressField()
    create_time = models.DateTimeField()
    update_time = models.DateTimeField(auto_now_add=True)
    order_id = models.CharField(max_length=20)
    log = models.CharField(max_length=2000)#报文
    username = models.CharField(max_length=32)
    password = models.CharField(max_length=32)
    passanger = models.CharField(max_length=200)
    visited_url = models.URLField()
    remark = models.CharField(max_length=400)
    session_id = models.CharField(max_length=64)
    def __unicode__(self):
        return '%s,%s,%s,%s,%s,%s' %(self.order_id,self.username,self.password,self.passanger,self.create_time,self.ip)
class User(models.Model):
    #用户表记录我们网站的账号和密码, 以及用户12306的账号密码, 乘车人信息, 手机号, 邮箱, 身份证这些信息, 用户首次登录12306认证之后, 就不需要再登陆12306了
    username = models.CharField(max_length=32)
    password = models.CharField(max_length=32)
    passengerInfo = models.CharField(max_length=128)
    phone_id = models.CharField(max_length=32)
    email = models.EmailField()
    idCard = models.CharField(max_length=32)#身份证
    remark = models.CharField(max_length=400)
    create_time = models.DateTimeField()
    update_time = models.DateTimeField(auto_now_add=True)
    bankCard = models.CharField(max_length=64)#银行卡
    state = models.IntegerField() #记录用户是否有效
    passengerStyle = models.CharField(max_length=8)#乘客类型
    def __unicode__(self):
        return '%s,%s,%s'%(self.passengerInfo,self.phone,self.email,self.idCard)